const fs = require('fs')
const http = require('http')
const {
    getUrlAndNameMore
} = require('./getUrlAndNameMore')
const {
    getUrlAndNameSingle
} = require('./getUrlAndNameSingle')
const path = `\\..\\Data\\singerMusicInfo\\`

fs.readFile(__dirname + `\\..\\Data\\singerInfo.json`, (err, data) => {
    if (err) {
        console.log('err')
        return
    }
    let source = JSON.parse(data),
        count = 0,
        len = source.length

    for (let i = 0; i < len; i++) {
        fs.readFile(__dirname + "\\..\\Data\\singerMusicInfo\\" + source[i].id + ".json", (error, data) => {
            if (error) {
                for (let item of source) {
                    if (item.id === source[i].id) {
                        console.log(item, ++count)
                        // if (item.hasPage) {
                        //     getUrlAndNameMore(item.url, item.singer, item.id)
                        // } else {
                        //     getUrlAndNameSingle(item.url, item.singer, item.id)
                        // }
                    }
                }
                return
            }

        })
    }
})